<<<<<<< HEAD
const htmlWebpackplugin = require('html-webpack-plugin')
const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const webpack = require('webpack')

module.exports = {
    entry: './src/app.js', // 入口
    output: {
      path: path.resolve(__dirname, 'dist/'),
      filename: 'assets/js/build.js',
      publicPath: '/' // 所有资源的基础路径, 而且一定是 / 结尾
    },
    plugins: [
        new htmlWebpackplugin({
            filename: 'index.html',
            template: 'src/index.html'
        }),
        new CleanWebpackPlugin([
          'dist'
        ]),
        new webpack.HotModuleReplacementPlugin()
    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                // exclude: /node_modules/,
                use: [{
                    loader: 'babel-loader'
                }],
                exclude: [
                    path.resolve(__dirname, 'node_modules')
                ]
            },
            // 处理css文件中出现的url, 会自动帮你引入里面要引用的模块
            {
                test: /\.css$/,
                use: ['style-loader', {
                    loader: 'css-loader',
                    options: {
                        modules: true,
                        localIdentName: '[path]-[name]-[local]-[hash:base64:6]'
                    }
                }, 'sass-loader'],
                exclude: [
                    path.resolve(__dirname, 'node_modules'),
                    path.resolve(__dirname, 'src')
                ]
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader', 'sass-loader'],
                include: [
                    // path.resolve(__dirname, 'node_modules'),
                    path.resolve(__dirname, 'src')
                ]
            },
            {
              test: /\.scss$/,
              use: [
                  'style-loader', 
                  {
                      loader: 'css-loader',
                      options: {
                          modules: true
                      }
                  }, 
                  'sass-loader']
            },
            // file-loader
            // 1. 把资源移动到输出目录
            // 2. 返回最终引入资源的url
            {
                test: /\.(jpg|png|gif|jpeg)$/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 10000, // 10kb 1kb ~= 1024 byt 小于10kb 的图片就用 urlloader 进行编码
                        name: 'assets/img/[name]_[hash:6].[ext]'
                    }
                }]
            },
            {
              test: /\.(ttf|eot|woff|woff2|svg)$/,
              use: [{
                loader: 'file-loader',
                options: {
                  name: 'assets/fonts/[name]_[hash:6].[ext]' // 默认的显示方式 [hash].[ext]
                }
              }]
            }
        ]
    },
    devServer: {
      port: 9090,
      contentBase: './src',

      // 服务器打包资源输出后的路径
      publicPath: '/',
      hot: true,
      inline: true
    }
=======

const htmlWebpackplugin = require('html-webpack-plugin')
const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const webpack = require('webpack')

module.exports = {
    entry: './src/app.js', // 入口
    output: {
      path: path.resolve(__dirname, 'dist/'),
      filename: 'assets/js/build.js',
      publicPath: './' // 所有资源的基础路径, 而且一定是 / 结尾
    },
    plugins: [
        new htmlWebpackplugin({
            filename: 'index.html',
            template: 'src/index.html'
        }),
        new CleanWebpackPlugin([
          'dist'
        ]),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        })
    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                // exclude: /node_modules/,
                use: [{
                    loader: 'babel-loader'
                }],
                exclude: [
                    path.resolve(__dirname, 'node_modules')
                ]
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader', 'sass-loader']
            },
            {
              test: /\.scss$/,
              use: [
                  'style-loader', 
                  {
                      loader: 'css-loader',
                      options: {
                          modules: true
                      }
                  }, 
                  'sass-loader']
            },
            // file-loader
            // 1. 把资源移动到输出目录
            // 2. 返回最终引入资源的url
            {
                test: /\.(jpg|png|gif|jpeg)$/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 10000, // 10kb 1kb ~= 1024 byt 小于10kb 的图片就用 urlloader 进行编码
                        name: 'assets/img/[name]_[hash:6].[ext]'
                    }
                }]
            }
        ]
    },
    devServer: {
      port: 9090,
      contentBase: path.resolve(__dirname, 'src/'),
      // 服务器打包资源输出后的路径
      publicPath: '/',
      hot: true,
      open: true
    }
>>>>>>> f370ae4f341f7124ba579532c58e53bf97c156a9
}